<template>
  <div class="liveDataWrap classMain">
   
    <van-nav-bar
      class="selfNavBar"
      left-text="首页"
      title="容灾能力"
      left-arrow
      :right-text="areaName"
      @click-left="onClickLeft"
      @click-right="onClickRight"
    >
      <van-icon name="location-o" slot="right" />
      <span slot="right" class="rights"> {{ cityName }}{{ areaName }}</span>
    </van-nav-bar>
    <div class="newContentArea">
      <!--头部-->

      <div class="tabbarAndChartsAreanone">
        <geoPosition
          @closrbtn="closrbtn"
          @closrbtn1="closrbtn1"
          style="width: 100%;height: 100%; position: absolute; top: 0;"
          :key="refreshKey"
          :location="location"
          :paramsName="paramsName"
        ></geoPosition>
      </div>

      <!-- v-show="zhedie" -->
      <div class="tabbarAndChartsArea00" v-if="zhedie">
        <div id="text1">当日小时预报</div>
        <div class="xiaoshi">
          <div class="tabbarAndChartsArea01">
            <div class="topText">
              <div>
                时间
              </div>
              <div>
                <img src="../assets/power/powericon/wendu.png" alt="" />温度
              </div>
              <div>
                <img src="../assets/power/powericon/shidu.png" alt="" /> 湿度
              </div>
              <div>
                <img src="../assets/power/powericon/fengsu.png" alt="" />风速
              </div>
              <div>
                <img src="../assets/power/powericon/jiangyu.png" alt="" />降雨
              </div>
            </div>
            <div
              class="bottomText"
              @click="getcolor(item, index)"
              v-for="(item, index) in columns0"
              :key="Number(index)"
            >
              <div>{{ item.dataTime }}</div>
              <div>{{ item.temp }}</div>
              <div>{{ item.rh }}</div>
              <div>{{ item.ff }}</div>

              <div>{{ item.rain }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <comArea
      v-if="showArea"
      @closeEmit="showArea=false"
      @confirmEmit="confirmEmitMet"
      :arr="arr"
  
    >
    </comArea>
  </div>
</template>
<script type="text/javascript">
import ldTrendChartOpt from '../components/mixins/ldTrendChartOpt.js'
import area from '@/components/mixins/area.js'
import staTable from '@/components/liveData/staTable.vue'
import geoPosition from '@/components/power/geoPosition.vue'
import meteoroHomeApi from '@/service/home.js'
import myTabbar from '@/components/common/myTabbar.vue'
import myTabbarItem from '@/components/common/myTabbarItem.vue'
import TransformationApi from '../service/power.js'

export default {
  mixins: [ldTrendChartOpt, area],

  data() {
    return {
      active: 1,
      topActive: 0,
      columns: [],
      datlist: '',
      wendulist: [],
      shuaxin: false,
      index1: -1,
      indextq: '0',
      columns0: [],
      zhedie: false,
      Today: [],
      weatherInfo: {},
      formatWordTime: {},
      showEcharts: false,
      echartsLiveName: '温度曲线',
      refreshKey: 0,
      location: [],
      arr: [],
      paramsName:''
    }
  },
  created() {
    // this.getChart()

    //echarts图表x轴
    this.ldTrendChartOpt.xAxis.data = this.$util.getNowBeforeHour()
  },

  mounted() {
    // this.getChart()
    this.paramsName=this.$route.query.name
    console.log();
    //天气信息
    this.weatherInfo = this.$store.getters.saveWeatherInfo
    //获取当前小时之前前24小时，
    this.formatWordTime = this.$util.formatWordTime()
    //请求当前到之前前24小时的天气信息
    this.getWeatherInfo()
  },
  watch: {
    topActive() {
      this.topActiveChange()
    },
    areaName() {
      this.getWeatherInfo()
    },
  },
  components: {
    staTable,
    geoPosition,
    myTabbar,
    myTabbarItem,
  },
  methods: {
    refresh() {
      this.refreshKey += 1
    },

    getclick(index, item) {
      this.datlist = item.yikeMonthDateofweek
    },
    //点击折叠
    closrbtn() {
      this.zhedie = true

      this.getWeatherInfo()
    },
    //点击展开
    closrbtn1() {
      this.zhedie = false
    },

    getcolor(item, index) {
      this.index1 = index
    },

    onClickLeft() {
      if (this.$route.query.name != undefined) {
        this.$router.push({
          name: 'message',
          query: {
            feature: featureslist,
            power: 'power',
          },
        })
      } else {
        this.$router.go(-1)
      }
    },
    onClickRight() {
      this.showArea = true
      this.arr = [this.cityName, this.areaName]
    },
    onChange(index) {
      this.$toast(index)
    },
    //请求当前到之前前24小时的天气信息
    getWeatherInfo() {
      var city = this.cityName

      var datetime = new Date()
      var year = datetime.getFullYear()
      var month =
        datetime.getMonth() + 1 < 10
          ? '0' + (datetime.getMonth() + 1)
          : datetime.getMonth() + 1
      var date =
        datetime.getDate() < 10 ? '0' + datetime.getDate() : datetime.getDate()

      // return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;//返回 YYYY-MM-DD HH:MM:SS

      var startime =
        year + '-' + month + '-' + date + ' ' + '00' + ':' + '00' + ':' + '00'
      var endtime =
        year + '-' + month + '-' + date + ' ' + '23' + ':' + '00' + ':' + '00'
      TransformationApi.Transformation({
        startTime: startime,
        endTime: endtime,
        provice: '山西省',
        city: this.cityName,
        cnty: '无',
      }).then((res) => {
        this.columns0 = res.data
      })

 
    },
    confirmEmitMet(value) {
      this.cityName = value[1].name
      this.areaName = value[2].name
      this.arr = [this.cityName, this.areaName]
      this.getWeatherInfo()
      this.$util.Convertlatitude(value).then((res) => {
      console.log(res);
        this.showArea = false
        this.location = res
       map.setCenter(this.location);
      
      })
    },
    closeAreaMet() {
      this.showArea = false
    },
    //走势图设置
    topActiveChange() {},
    BottomClickMet(index) {
      this.active = index
    },
    // initData() {
    //   alert(1)
    // },
  },
}
</script>
<style type="text/css" lang="less" scoped>
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

body,
html {
  width: 100%;
  height: 100%;
  position: relative;
}
#text1 {
  font-size: 14px;
  font-size: 15px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #101010;
  text-align: left;
}
.chakan {
  position: absolute;
  top: 355px;
  color: #fff;
  font-size: 14px;
  z-index: 9999;
}
.rights {
  color: #fff;
}

/deep/ .jrain1::-webkit-scrollbar-thumb {
  /*滚动条里面小方块*/
  border-radius: 10px;
}

/deep/ .jrain1::-webkit-scrollbar-track {
  /*滚动条里面轨道*/

  border-radius: 10px;
  background-color: transparent;
}

.jrain1 {
  display: flex;

  overflow-x: auto;
  padding: 8px;
  width: 100%;
  box-sizing: border-box;
  color: #fff;

  // height: 80px;
  // background-color:pink;

  .jrainsun1 {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 4px;
    font-size: 12px;
    // height: 50px;
    // border-bottom: 3px solid #fff;
    // line-height: 40px;
    // border-right: 1px solid red;
    position: relative;

    flex: 0 0 50px;

    .newimage {
      width: 20px;
      height: 20px;

      img {
        width: 100%;
        height: 100%;
      }
    }
    span {
      font-size: 13px;
    }

    // background-color: aquamarine;
  }

  .jrainsun1::before {
    content: '';
    height: 30px;
    position: absolute;
    width: 1px;
    display: block;
    float: left;
    right: -3px;
    height: 69px;
    background: white;
    margin-top: 14px;
  }
}

.liveDataWrap {
  position: relative;
  width: 100%;
  height: 100%;

  .actives {
    background-color: #a3bdfb;
    border-radius: 10px;
    color: #8600f8 !important;
  }

  .topBgPic {
    width: 100%;
    height: 100%;
  }

  .newContentArea {
    position: absolute;
    width: 100%;
    height: 100%;
    box-sizing: border-box;

    .titleArea {
      position: relative;
      left: 0;
      top: 0;

      img {
        width: 100%;
      }

      .titleCon {
        position: absolute;
        top: 6px;
        .px2rem(left, 25px);
        color: white;
        font-size: 16px;
        font-weight: bold;
      }

      .pageTextStyle {
        position: absolute;
        left: 0;
        right: 0;
        top: 20px;
      }

      .pageTextStyleTow {
        position: absolute;
        left: 0;
        right: 0;
        top: 100px;
      }
    }
  }

  .tabbarAndChartsArea {
    position: absolute;
    left: 0;
    right: 0;
    top: 60px;
    width: 100%;
    height: 90%;
    background-color: #ecf2ff;
    // padding: 10px;

    // border-radius: 20px;
    // box-sizing: border-box;
  }
  .tabbarAndChartsAreanone {
    position: absolute;
    left: 0;
    right: 0;

    width: 100%;
    height: 100%;
    background-color: #ecf2ff;
    // padding: 10px;

    // border-radius: 20px;
    // box-sizing: border-box;
  }

  .tabbarAndChartsArea0 {
    position: absolute;
    left: 0;
    right: 0;
    top: 380px;
    width: 100%;
    height: 110px;
    text-align: center;
    /*水平居中 */
    line-height: 40px;
    /*垂直居中 */

    // border-radius: 5px;
    // box-sizing: border-box;
  }

  .tabbarAndChartsArea1 {
    display: inline-block;
    position: relative;
    top: 20px;
    width: 16%;
    height: 90px;
    border-right: 2px solid rgb(105, 105, 117);

    // padding: 20px 10px 30px;

    // box-sizing: border-box;
  }

  .tabbarAndChartsArea01 {
    // float: left;
    // display: inline-block;
    position: relative;
    width: 100%;
    height: 210px;
    overflow-y: auto;
    font-size: 10px;
    color: #fff;
    .topText {
      display: flex;
      justify-content: space-evenly;
      font-size: 13px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #101010;
      div {
        display: flex;
        justify-content: center;
        align-items: center;
        img {
          width: 15px;
          height: 15px;
          margin-right: 4px;
          margin-top: 1px;
        }
      }
    }

    .bottomText {
      display: flex;

      justify-content: space-around;
      font-size: 12px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #101010;
      //   flex-wrap: nowrap;
      div {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100px;
        height: 50px;
        line-height: normal; /* 可能存在的过大行高 */
      }
    }
    .bottomText:nth-child(even) {
      background: #f7f7f7;
    }
  }
  .tabbarAndChartsArea012 {
    flex: 0 0 60px;

    float: left;
    display: inline-block;
    position: relative;
    width: 12%;
    height: 210px;
    border-right: 2px solid #a0bcfb;
    font-size: 10px;
    color: #fff;

    img {
      display: block;
      width: 20px;
      height: 20px;
      margin: auto;
      margin-top: 10px;
    }
  }

  .tabbarAndChartsArea2 {
    position: absolute;
    top: 0px;
    width: 90%;
    height: 33%;
    flex: 0 0 80px;
  }

  .tabbarAndChartsArea03 {
    position: absolute;
    top: 0px;
    width: 90%;
    height: 15.5%;
  }

  .tabbarAndChartsArea07 {
    position: absolute;
    top: 12px;
    width: 90%;
    height: 30%;
  }

  .tabbarAndChartsArea04 {
    position: absolute;
    top: 15%;
    width: 90%;
    height: 12.5%;
  }

  .tabbarAndChartsArea05 {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: absolute;
    top: 30%;
    width: 90%;
    height: 12.5%;
    flex: 0 0 80px;
  }

  .tabbarAndChartsArea06 {
    position: absolute;
    top: 45%;
    width: 90%;
    height: 12.5%;
    flex: 0 0 80px;
  }

  .tabbarAndChartsArea07 {
    position: absolute;
    top: 60%;
    width: 90%;
    height: 12.5%;
    flex: 0 0 60px;
  }

  .tabbarAndChartsArea08 {
    position: absolute;
    top: 62.5%;
    width: 90%;
    height: 12.5%;
  }

  .tabbarAndChartsArea09 {
    position: absolute;
    top: 70%;
    width: 90%;
    height: 12.5%;
    flex: 0 0 80px;
  }

  .tabbarAndChartsArea3 {
    position: absolute;
    top: 33%;
    width: 90%;
    height: 33%;
    flex: 0 0 80px;
  }

  .tabbarAndChartsArea4 {
    position: absolute;
    top: 66%;
    width: 90%;
    height: 33%;
    flex: 0 0 60px;
  }

  .tabbarAndChartsArea00 {
    // display: flex;
    overflow-x: auto;

    position: absolute;
    width: 100%;
    bottom: 0;
    z-index: 9;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    text-align: center;

    box-sizing: border-box;
    /*水平居中 */
    line-height: 40px;
    color: #333333;
    /*垂直居中 */
    // border-radius: 20px;
    background-color: #fff;
  }

  .xiaoshi::-webkit-scrollbar {
    display: none;
  }

  .baseInfoArea {
    padding: 20px;

    .baseLine {
      overflow: hidden;
      font-size: 16px;
      padding-bottom: 14px;
      color: white;
    }

    .baseLine:last-child {
      padding-bottom: 0;
    }

    .baseLineLeft {
      float: left;
      width: 45%;
    }

    .baseLineRight {
      float: left;
      width: 55%;
    }

    .baseLineImg {
      width: 18px;
      vertical-align: middle;
      margin-right: 5px;
    }

    .colorCon {
      vertical-align: middle;
    }

    .colorLiner {
      vertical-align: middle;
    }
  }

  .topTabbarArea {
    .vanSelfTabs img {
      width: 20px;
      margin-right: 3px;
      vertical-align: middle;
    }

    /deep/ .van-tab--active {
      color: #1989fa;
    }

    /deep/ .van-tabbar--fixed {
      position: relative;
      left: 0;
      top: 0;
    }

    /deep/ .van-tabbar,
    /deep/ .van-tabbar-item--active {
      border-radius: 10px;
    }
  }

  #ditu {
    width: 100%;
    position: absolute;
    top: 725px;
    // bottom: 0;
    height: 200px;
    background: url('../assets/dtwgn.png') top no-repeat;
    background-size: cover;
  }

  .bottomConditu {
    // background-color: rgb(172, 163, 163);
    text-align: center;
    position: absolute;
    // z-index: 9999;
    color: #fff;
    bottom: 20px;
    width: 100%;
    font-size: 16px;

    // margin-bottom: 30px;
  }

  .contentArea {
    margin: 0 10px;
    padding: 30px 10px;
    background: white;
    //box-sizing:border-box;
    .px2rem(height, 368px);
    width: auto;
    overflow: scroll;
    position: relative;
    left: 0;
    top: 0;
  }

  .contentAreaActive {
    padding: 20px 10px;
    .px2rem(height, 428px);
    border-radius: 5px;
    overflow: hidden;
  }

  .echartsLive {
    margin-top: 20px;
    padding: 0 20px;
    font-size: 14px;
    color: #646566;

    .echartsName {
      position: absolute;
      top: 17%;
      color: #333;
      font-weight: bold;
    }
  }

  .echartsSelfStyle {
    height: 270px;
  }

  .LiveDatabottomTabbar {
    position: absolute;
    .px2rem(left, 20px);
    .px2rem(right, 20px);
    top: 630px;
    height: 40px;
    overflow: hidden;

    .leftMyButton {
      float: left;
    }

    .RightMyButton {
      float: right;
    }
  }
}
</style>
